package com.atguigu.gmallsugar.mapper;



import com.atguigu.gmallsugar.pojo.SpuStats;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.math.BigDecimal;
import java.util.List;


public interface ProductMapper {
    @Select("SELECT sum(order_amount) AS gmv\n" +
        "FROM product_stats_2021\n" +
        "WHERE toYYYYMMDD(stt) = #{date}\n")
     BigDecimal getGMVFromCK(@Param("date") int date);


    @Select("select spu_name,sum(order_amount) order_amount  \n" +
        "from product_stats_2021 where toYYYYMMDD(stt)=#{date} \n" +
        "group by spu_name order by order_amount desc limit #{limit}\n")
    List<SpuStats> getGMVBySpu(@Param("date") int date, @Param("limit") int limit);
}

